<?php

namespace Project\ScrumBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UserstoriesType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $id = $options['attr'];
        $builder
        ->add('role', 'text')
        ->add('action', 'text')
        ->add('but', 'textarea')
        ->add('ordre_priorite', 'choice', array(
        'choices' => array('basse' => 'Basse', 'moyenne' => 'Moyenne','haute' => 'Haute', 'prioritaire' => 'Prioritaire'),
        ))
        ->add('ref_projet', 'entity', array(
            'class' => 'Project\ScrumBundle\Entity\Projet',
            'property' => 'nom',
            'label' => 'Projet : ',
            'query_builder' => function (\Doctrine\ORM\EntityRepository $er) use ($id) {
                return $er->createQueryBuilder('projet')
                                ->where('projet.refClient = :param')
                                ->setParameter('param', $id);
            },
        ));
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'Project\ScrumBundle\Entity\Userstories'
        ));
    }

    public function getName() {
        return 'project_scrumbundle_userstoriestype';
    }

}
